home *** CD-ROM | disk | FTP | other *** search
- Path: news.genie.net!usenet
- From: i.einman@genie.com (IAN J. EINMAN)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: SAS-C and Interrupts
- Date: 7 Feb 1996 07:23:53 GMT
- Organization: via GEnie Services (1-800-638-9636 or info@genie.com)
- Sender: i.einman@genie.com (IAN J. EINMAN)
- Message-ID: <4f9k29$lt2@rock101.genie.net>
- NNTP-Posting-Host: rock103.is.ge.com
-
- __interrupt __saveds IRoutine(void)
- {
- blah blah blah++
- }
-
- The __interrupt insures SAS will set the CCR on return, and disables stackchecking.
- Be sure that stack extension is turned off.
-
- Finally, the __saveds is desperately needed if you try to access variables. The
- C code will access your variables as an offset from A4.
-
- For example,
-
- count += 5;
-
- would become
-
- addq.l #5,_count(a4)
-
- The problem is this. Without __saveds, your program (C-code) will not have a4 set.
-
- Imagine this
-
- assembly code:
- move.l a3,a4
- lea 24(a4),a0 (just misc code)
- addq.l #1,d0
- jsr _interrupt(pc)
- move.l d0,(a3)+
- rts
-
- C code
- {
- count++; addq.l #1,count(a4)
- } rts
-
- This will crash, since A4 was tampered with in the Asm part previously. The __saveds
- keyword will change the "interrupt"routine to look more like this:
-
- C code
- __saveds interrupt(void)
- {
- move.l __saveds(pc),a4
- count ++; addq.l #1,count(a4)
- } rts
-
-
- Hope this helps.
-
- Ian J. Einman
- i.einman@genie.com
-
-